From 3cd3b7ac9ffa96dcd4302742ba03b1dfabb6002c Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Wed, 30 Sep 2015 11:15:32 +0300 Subject: [PATCH] Make lines short to pass phpcs in 3 files under tests/phpunit/includes/ Bug: T102614 Change-Id: I8f3d570fb6e9866d4376f42d4efa05f9c5e7f14d --- .../logger/monolog/AvroFormatterTest.php | 5 ++- .../filerepo/MigrateFileRepoLayoutTest.php | 34 +++++++++++++++---- .../includes/utils/BatchRowUpdateTest.php | 14 +++++--- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php b/tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php index 44242ed279..b0df61639c 100644 --- a/tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php +++ b/tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php @@ -34,7 +34,10 @@ class AvroFormatterTest extends MediaWikiTestCase { public function testSchemaNotAvailable() { $formatter = new AvroFormatter( array() ); - $this->setExpectedException( 'PHPUnit_Framework_Error_Notice', "The schema for channel 'marty' is not available" ); + $this->setExpectedException( + 'PHPUnit_Framework_Error_Notice', + "The schema for channel 'marty' is not available" + ); $formatter->format( array( 'channel' => 'marty' ) ); } diff --git a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php index 3f08fd268d..c839bc42cf 100644 --- a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php +++ b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php @@ -48,10 +48,16 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase { 'backend' => $backend ) ) ); - $repoMock->expects( $this->any() )->method( 'getMasterDB' )->will( $this->returnValue( $dbMock ) ); + $repoMock + ->expects( $this->any() ) + ->method( 'getMasterDB' ) + ->will( $this->returnValue( $dbMock ) ); $this->migratorMock = $this->getMock( 'MigrateFileRepoLayout', array( 'getRepo' ) ); - $this->migratorMock->expects( $this->any() )->method( 'getRepo' )->will( $this->returnValue( $repoMock ) ); + $this->migratorMock + ->expects( $this->any() ) + ->method( 'getRepo' ) + ->will( $this->returnValue( $repoMock ) ); $this->tmpFilepath = TempFSFile::factory( 'migratefilelayout-test-', 'png' )->getPath(); @@ -59,7 +65,12 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase { $hashPath = $repoMock->getHashPath( $filename ); - $status = $repoMock->store( $this->tmpFilepath, 'public', $hashPath . $filename, FileRepo::OVERWRITE ); + $status = $repoMock->store( + $this->tmpFilepath, + 'public', + $hashPath . $filename, + FileRepo::OVERWRITE + ); } protected function deleteFilesRecursively( $directory ) { @@ -85,7 +96,10 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase { } public function testMigration() { - $this->migratorMock->loadParamsAndArgs( null, array( 'oldlayout' => 'name', 'newlayout' => 'sha1' ) ); + $this->migratorMock->loadParamsAndArgs( + null, + array( 'oldlayout' => 'name', 'newlayout' => 'sha1' ) + ); ob_start(); @@ -105,10 +119,18 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase { . '/' . $sha1; - $this->assertEquals( file_get_contents( $expectedOriginalFilepath ), $this->text, 'New sha1 file should be exist and have the right contents' ); + $this->assertEquals( + file_get_contents( $expectedOriginalFilepath ), + $this->text, + 'New sha1 file should be exist and have the right contents' + ); $expectedPublicFilepath = $this->tmpPrefix . '-public/f/f8/Foo.png'; - $this->assertEquals( file_get_contents( $expectedPublicFilepath ), $this->text, 'Existing name file should still and have the right contents' ); + $this->assertEquals( + file_get_contents( $expectedPublicFilepath ), + $this->text, + 'Existing name file should still and have the right contents' + ); } } diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/includes/utils/BatchRowUpdateTest.php index 4684658a9d..082ac821bd 100644 --- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php @@ -123,11 +123,14 @@ class BatchRowUpdateTest extends MediaWikiTestCase { /** * @dataProvider provider_readerSetFetchColumns */ - public function testReaderSetFetchColumns( $message, array $columns, array $primaryKeys, array $fetchColumns ) { + public function testReaderSetFetchColumns( + $message, array $columns, array $primaryKeys, array $fetchColumns + ) { $db = $this->mockDb(); $db->expects( $this->once() ) ->method( 'select' ) - ->with( 'some_table', $columns ) // only testing second parameter of DatabaseBase::select + // only testing second parameter of DatabaseBase::select + ->with( 'some_table', $columns ) ->will( $this->returnValue( new ArrayIterator( array() ) ) ); $reader = new BatchRowIterator( $db, 'some_table', $primaryKeys, 22 ); @@ -148,7 +151,8 @@ class BatchRowUpdateTest extends MediaWikiTestCase { ), array( - 'With multiple primary keys the first conditions must use >= and the final condition must use >', + 'With multiple primary keys the first conditions ' . + 'must use >= and the final condition must use >', // Expected second iteration array( "( id_field = '3' AND foo > '103' ) OR ( id_field > '3' )" ), // Primary key(s) @@ -164,7 +168,9 @@ class BatchRowUpdateTest extends MediaWikiTestCase { * * @dataProvider provider_readerSelectConditions */ - public function testReaderSelectConditionsMultiplePrimaryKeys( $message, $expectedSecondIteration, $primaryKeys, $batchSize = 3 ) { + public function testReaderSelectConditionsMultiplePrimaryKeys( + $message, $expectedSecondIteration, $primaryKeys, $batchSize = 3 + ) { $results = $this->genSelectResult( $batchSize, $batchSize * 3, function() { static $i = 0, $j = 100, $k = 1000; return array( 'id_field' => ++$i, 'foo' => ++$j, 'bar' => ++$k ); -- 2.20.1